package com.gxa.controller.abnormal;

import com.gxa.common.R;
import com.gxa.service.AbnormalWarningService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.*;

@Controller
@Api(value = "异常预警",tags = "异常预警接口API")
@RequestMapping("/abnormalwarning")
public class AbnormalWarningController {

    @Autowired
    private AbnormalWarningService abnormalWarningService;

    @RequestMapping(value = "/findAll",method = RequestMethod.GET)
    @ApiOperation(value = "查询所有异常预警接口",notes = "查询所有异常预警",httpMethod = "GET",response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "pageSize",value = "每页显示记录数",required = true,dataType = "int",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="查找成功"),
            @ApiResponse(code=400,message="参数格式不对"),
            @ApiResponse(code=404,message="找不到此请求"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R findAll(Integer currentPage,Integer pageSize){

        R r = new R();
        r.setCode(200);
        r.setMsg("查询成功");
        r.setData(abnormalWarningService.findAll(currentPage,pageSize));
        return r;
    }

    @RequestMapping(value = "/selectByName",method = RequestMethod.GET)
    @ApiOperation(value = "根据条件查询",notes = "条件查询",httpMethod = "GET",response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name",value = "姓名",required = false,dataType = "string",paramType = "query"),
            @ApiImplicitParam(name = "sex",value = "性别",required = false,dataType = "string",paramType = "query"),
            @ApiImplicitParam(name = "idCard",value = "身份证号",required = false,dataType = "string",paramType = "query"),
            @ApiImplicitParam(name = "phoneNum",value = "联系电话",required = false,dataType = "string",paramType = "query"),
            @ApiImplicitParam(name = "status",value = "状态",required = false,dataType = "string",paramType = "query"),
            @ApiImplicitParam(name = "registrationDate",value = "上报日期",required = false,dataType = "date",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="查找成功"),
            @ApiResponse(code=400,message="参数格式不对"),
            @ApiResponse(code=404,message="找不到此请求"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R selectByName(Integer currentPage,Integer pageSize,String name,String sex,String idCard,String phoneNum,String status,Date registrationDate){
        R r = new R();
        r.setCode(200);
        r.setMsg("查询成功");
        r.setData(abnormalWarningService.selectByName(currentPage, pageSize, name, sex, idCard, phoneNum, status, registrationDate));
        return r;
    }

    @RequestMapping (value = "/turnDiagnosis",method = RequestMethod.POST)
    @ApiOperation(value = "转为确诊病例接口",notes = "转为确诊",httpMethod = "POST", response = R.class)
    @ApiImplicitParam(name = "id",value = "密接人员编号",required = true,dataType = "int",paramType = "query")
    @ApiResponses({
            @ApiResponse(code=200,message="操作成功"),
            @ApiResponse(code=400,message="参数格式不对"),
            @ApiResponse(code=404,message="找不到此请求"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R turnDiagnosis(int id){
        R r = new R();
        r.setCode(200);
        r.setMsg("操作成功");
        r.setData(abnormalWarningService.turnDiagnosis(id));
        return r;
    }

}
